/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Image; //image ;P
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class Menu extends JPanel implements ActionListener {
    
    
    Image backgroundImage;
    Image startButton;
    int x = 0;
    int y = 0;
    GameFrame gf;


    public Menu(GameFrame gf) {
            this.gf = gf;
            startButton();
           
            JButton quitButton = new JButton("Quit");
            quitButton.setBackground(Color.red);
            quitButton.addActionListener(this);
            add(quitButton);

    }
    public void startButton(){

        ImageIcon startImage = new ImageIcon ("images/megaman/m1.jpg");
        JButton startButton = new JButton("Start",startImage); //använder "start" och "quit" nere i actionlistener

        startButton.setBorderPainted(false);
        startButton.setContentAreaFilled(false);
        startButton.setFocusPainted(false);
        startButton.setOpaque(false);
        startButton.addActionListener(this);

        add(startButton);


    }
    public void drawTheMenu( Graphics g) {

      
        


    }
    public void paintComponent ( Graphics g )   {
       
        //super.paintComponent( g );
        menuBackground(g);
        drawTheMenu(g);


        repaint(); //Gör att paintComponent körs igen!!!
    } // end of paintComponent


    

    public void menuBackground(Graphics g){

        backgroundImage = new ImageIcon("images/space.gif").getImage();

        /*if(megamanCounter == 1)
            backgroundImage = new ImageIcon("images/megaman/m1.jpg").getImage(); //source - (2)
        if(megamanCounter == 2)
            backgroundImage = new ImageIcon("images/megaman/m3.jpg").getImage(); //source - (2)
        if(megamanCounter == 3)
            backgroundImage = new ImageIcon("images/megaman/m2.jpg").getImage(); //source - (2)
        if(megamanCounter == 4)
            backgroundImage = new ImageIcon("images/megaman/m3.jpg").getImage(); //source - (2)


        megamanCounter++;
        if(megamanCounter >= 5)
            megamanCounter = 1;*/

         // följer muspekaren, behöver inte ha mouselistener för detta
        // fuckar dock om muspekaren hamnar utanför panelen.
        g.drawImage(backgroundImage, x, y,800, 600, this); // checka keyPressed för att se hur rörelser går till
    }

    public void actionPerformed(ActionEvent e) {
       if (e.getActionCommand().equals("Start"))
        {
            gf.setFrame(true);
        }
    }
}
